package com.epam.lissina.task;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.epam.lissina.entity.IParagraph;
import com.epam.lissina.entity.Paragraph;
import com.epam.lissina.entity.Sentence;
import com.epam.lissina.entity.Text;

public class PersonalTask {

	public static List<Sentence> sentencesAscendingNmberWords(Text text) {
		List<Sentence> sentenceList = new ArrayList<Sentence>();
		for (IParagraph paragraph : text.getParagraph()) {
			if (paragraph instanceof Paragraph) {
				sentenceList.addAll(((Paragraph) paragraph).getSentence());
			}
		}
		Collections.sort(sentenceList, Sentence.wordCountComparator);
		return sentenceList;
	}
}
